﻿using System;
using System.Text;

namespace Needle.Utils.Extensions
{
    /// <summary>
    /// StringBuilder extension methods
    /// </summary>
    public static class StringBuilderExtensions
    {
        /// <summary>
        /// Returns the contents of the StringBuilder and sets the length to zero.
        /// </summary>
        public static string Flush(this StringBuilder buffer)
        {
            if (buffer == null)
                throw new NullReferenceException();
            string value = buffer.ToString();
            buffer.Length = 0;
            return value;
        }
    }
}
